package cn.itcast.bos.service.bc.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.bc.StaffDao;
import cn.itcast.bos.domain.bc.Staff;
import cn.itcast.bos.service.bc.StaffService;

@Service("staffService")
@Transactional
public class StaffServiceImpl implements StaffService {
	@Autowired
	private StaffDao staffDao;

	public void saveStaff(Staff model) {
		staffDao.save(model);// spring data save 会不会智能 update ?
	}

	public Page<Staff> findAll(Pageable pageRequest) {
		// 分页查询结束
		return staffDao.findAll(pageRequest);
	}

	// 必须添加事务管理
	public void batchDelete(String paramIds) {
		// ids 切割
		String[] ids = paramIds.split(",");
		// 修改 update update.... Staff set deltag = 1 where id = ?
		for (String id : ids) {
			staffDao.batchDelete(id);
		}

	}

	public List<Staff> findAll() {
		// 作废的取派员不要 1 0
		return staffDao.findInUser();
	}

}
